<?php
/**
 * Created by PhpStorm.
 * User: liuhong
 * Date: 2019-04-10
 * Time: 10:50
 */

namespace app\service;


use app\model\OrdergoodsModel;
use think\Exception;

/**
 * 订单商品
 * Class OrdergoodsService
 * @package app\service
 */
class OrdergoodsService extends BaseService
{
    protected $orderGoodsModel;
    public function __construct()
    {
        $this->orderGoodsModel=new OrdergoodsModel();
    }


    /**
     * 查询订单商品信息
     * @param $where
     * @return array|bool
     */
    public function selectGoods($where){
        try{
            return $this->orderGoodsModel
                ->field('zkhb_order_goods.goods_num,zkhb_order_goods.order_id,zkhb_goods.*')
                ->join('zkhb_goods','zkhb_goods.id=zkhb_order_goods.goods_id')
                ->where($where)
                ->select()
                ->toArray();
        }catch (Exception $ex){
            LogService::S()->writeLog('Exception',$ex->getMessage());
            return false;
        }

    }


    /**
     * 新增商品信息
     * @param $addAll
     * @return int|string
     */
    public function addOrderGoods($addAll){
        return $this->orderGoodsModel->insertAll($addAll);
    }

}